package com.zx.JDK特性.jdk_17;

import org.junit.Test;

public class Main {

    @Test
    public void test01() {
        //switch 新增模式（预览版）
        Object obj = "";

//        Object o = null;
//        Object o = "";
        Object o = new SelectVO("1", "2");
//        Object o = new int[]{1, 2};
        switch (o) {
            case null -> System.out.println("首先判断对象是否为空，走空指针逻辑等后续逻辑");
            case String s -> System.out.println("判断是否为字符串，s:" + s);

            // 判断SelectVO或者 Record 都可以。一些record类的父类都是 Record
            //case SelectVO p -> System.out.println("判断是否为Record类型: " + p.toString());
            case Record p -> System.out.println("判断是否为Record类型: " + p.toString());

            case int[] arr -> System.out.println("判断是否为数组，展示int数组的长度" + arr.length);
            case Integer i -> System.out.println("判断是否为Intger对象,i:" + i);
            default -> System.out.println("Something else");
        }
    }

    @Test
    public void test02() {
        SelectVO vo = new SelectVO("1", "2");
        System.out.println(vo.label());
        System.out.println(vo.value());
    }


    public record SelectVO(String label, String value) {

    }

}
